perm filename LRNMUS.GL[UP,DOC]1 blob sn#120161 filedate 1974-09-23 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00006 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	ABSTRACT 
C00015 00003	MUSIC COMPILER, WORD CONVERSION, AND D/A PROGRAMS
C00023 00004	MISC. FILES
C00026 00005	ABRIDGED EDIT MODE COMMAND LIST
C00031 00006	CHANGES AND ADDITIONS
C00032 ENDMK
C⊗;
ABSTRACT 
LRNMUS is an information source for general music synthesis programs. 
Familiarity with the Monitor Command Handbook, MUSIC.TVR[UP,DOC], and
SCORE.LCS[UP,DOC] assumed.  Knowledge of SAIL (or ALGOL) is nice, but 
not required.  This file further assumes the user has access
to someone familiar with  AI Lab music programs who can fill in the gaps
which will undoubtedly exist between what you want to know and what is
supplied here.  This file attempts only to anticipate the broadest 
questions of procedure. "Ours is not the reason why..."



INPUT FOR MUSIC PROGRAMS

Input is made up of an instrument definition, a parameter list,and 
other information the compiler needs which we'll call the initializing list.
The Stanford music compiler reads this information from one or more 
files. Creating several files for this information is suggested.
However, the information described below can be added from the
console directly into NEWMUS. (In particular, SETSPEED, SEG, SYNTH, PRINT,
SEE, PLAY, and even instrument definitions can be writen directly from the
TTY into NEWMUS.  The advantage is you can change things "on the fly",
the disadvantage is that you must then retype the entire event if you
either leave the NEWMUS environment, or want to change something.)
			******
       WHAT FOLLOWS IS A TYPICAL USAGE OF THE MUSIC PROGRAMS
			******
		INITIALIZING LIST
	Create a file (maybe called INIT, or something).  Into it put the
following declarations:
	SETSPEED;⊂#OF CHANNELS⊃ ⊂SAMPLING RATE⊃  (don't forget ;)
(typical values: SETSPEED; 1 25000). This sets the sampling rate.
	ARRAY F2,F3,...,Fn(512);
where F2,...Fn are functions (sine waves, envelope functions, etc.)
to be loaded with the instrument. (512) is the current size of a
memory block. F1 is always supplied with NEWMUS as a sine wave.
This can be overriden of course.
	VARIABLE ⊂variable name⊃,⊂v.n.⊃,⊂v.n.⊃; if there are to be any.
	Other things can go into this, for instance, you can tell
yourself the next file to read by writing:
	PRINT "Next file name";
When the music compiler (NEWMUS) loads this file, it will print 
this statement afterwards.
	There is a model list in INIT[GL,JAM] which has all the 
above, plus an instrument MONITER which displays blocks as they are 
computed.
	Basicly you want to put everything in the initialization list
that you don't want to have to declare over and over again.
			******
		INSTRUMENT LIST
	Create a file for your instrument definiton.
Now that you have arrayed the functions, specify their shape with either 
SYNTH or SEG, e.g.:
 	SYNTH(F2); 1 1 999   (Note the location of the ;.)
This creates in F2 a sine wave with harmonic 1 (the fundamental) and 
amplitude 1. 999 terminates the SYNTH list.  There is an extended mode:
	SYNTH (F2); 99 1 1 90 1 999  where 99 enters the mode, 
harmonic = 1, amp.=1, phase angle =90degrees, offset constant=1, 999term.
	SEG(F3); 0 0 1 1 0 100 (Note the semicolon.)
This allows  functions to  be drawn  in line  segments. The  function
described  has amplitude 0 at  location 0, amp.  1 @ loc.1,  0 @ 100.
Typing location # 100 terminates SEG.  SYNTH and SEG functions can be
created while runing NEWMUS, and will display the waveform. Just type
the above  statements up to the ";", then hit ⊂cr⊃. The waveform will
begin displaying and instructions on how to alter it will be printed.
You  can see  existing functions  graphicly in  NEWMUS by  typing SEE
(⊂function name⊃);.

Now  the instrument:
	INSTRUMENT FUT;
	OSCIL(P4,MAG/P2,F2);
	OSCIL(U1,MAG*P3,F1);
	OUTA←OUTA+U2;
	END;
where: 

INSTRUMENT ⊂name⊃;
begins the instrument list. This is a special kind
of DO list which the music compiler can read.  Like any DO
list,   it   must   be  terminated   by   END;   see   below.

OSCIL(amplitude,frequency,function);
There are many kinds of oscils.
See the MUSIC  MANUAL listed in FILES, page 4 below.    

MAG
is  the magic number  specifying the  ratio of 512/sample  rate.
(The  length of stored functions  in NEWMUS is 512  samples long.  The
ratio (512/sampling  rate) establishes  a base  frequency which  when
mulltiplied by  the desired frequency  number (in this  case,P3) will
sample  the  512  increment long  function  at  intervals  which will
produce the desired frequency. A further explanation  of this subject
can be found in MUSIC.TVR[UP,DOC]. This is also a good question for
a music programer.

*Pn is  a   parameter  number.      

*Un is the output of a unit generater(numbered  in order  of  entry) 

*OUTA  is  the output  block absorbing  this instrument.

*END;(←note  semicolon;) this  ends the instrument list.

Comments can be added to this or any list by typing:
	COMMENT say anything here until you write a semicolon;

INSTRUMENT WRITING CONSIDERATIONS:
Newmus is set up so  that P1 always determines the begin  time of the
instrument. For instance, if you want FUT to play at time 0, P1 would
be listed in your note list  as 0. Also, P2 is reserved to  represent
the total duration of the note  being played. So, P2 does two things:
it  tells the system  how long to  make the file  the instrument will
play into, and it also  is available to determine the length  of time
the  instrument will actually  play.   You CAN have  the instrument's
duration controled in another variable, but  P2 must still be in  the
note list  to represent the  length of the  file the  instrument will
read  into.   This information  is  given here  instead of  under the
parameter list heading below because  it affects how you define  your
instruments as well as how you write their note lists.
 			******

		PARAMETER LIST

Here's where you tell the instrument what to play. 
Create a file for parameters.
	PLAY;INSTRUMENT NAME P1 P2 P3 P4 ...Pn; 
If you have the moniter display loaded,add here:
	MONITER time,duration,max. est. amplitude, display increment;
	(typical values MONITER 0 1 1000 2;
The parameter list must! end with 
	FINISH;
The play statement is like a specialized block in SAIL with PLAY;
replacing BEGIN, and FINISH; for END;
Please see INSTRUMENT WRITING CONSIDERATIONS  above.
MUSIC COMPILER, WORD CONVERSION, AND D/A PROGRAMS
The NEWMUS compiler will be used here. SCORE does much of the same
kinds of things, and is well documented in SCORE.LCS[UP,DOC].

	NEWMUS is a compiler, and is the vehicle by which instruments
	are coupled with their parameters.  One long file is
	created which contains the numeric representation of the waveform.
	Type:
R NEWMUS
	After some preliminary statements, it types:
Input?  
	Type file names of initialization ,inst. & notes one at a time.
	When it says "Input?" it expects a file name.  To do anything else,
	like to make declarations, write functions, or to write 
	instruments, etc. type ⊂cr⊃ first. To return to input mode, type ⊗⊂cr⊃.
	If you get an error message "Storage full", type ⊂CALL⊃,
	and restart using the FREEZE method, see below.
	Variables that are given with NEWMUS are the Hz for pitches 
	of the equal temperament scale: A:440, AS(A SHARP):466.16,...GS.
	Array F1 is given as a simple sine wave.
 	If you want to watch it compile, see MONITE[1,MUZ] below:
Output?  
	Name a file for storage of computed samples.
	The extension of the file name should be an intiger,(e.g. TEST.1).
	"MAX AMP" is part of data printed when compilation is complete 
	used to indicate the largest sample. Remember it.
	If you have no more input, then:
⊂CALL⊃

	NMUSIO is a program which converts one or more 18 bit sound files
	as produced by NEWMUS into one or more 12 bit soundfiles acceptable
	as input to the D/A converter.
	Type:
R NMUSIO
Input?   
	Type NEWMUS output file name.
Max Amp?  
	Write it in here.
Output?  
	Make up a storage location.
More input?
	Answer Y(es) or N(o).  If yes, NMUSIO asks
Finishing input?
	Y or N. NMUSIO will CALL itself.

	Type:
R DSKPLY
	will explane itself.
Or, type:
R MPLA to play multiple lists.
	If you are going to play more than one speaker, 
	after Input? type ⊂S⊃⊂cr⊃. Then follow directions.
	
				******
If you  are not working  in the  music room, you  can switch the  TTY
audio channel to channel  1 of the D/A by typing BREAK 4 U (See Audio
Switch Control, 2.9, Monitor Command  Manual). BUT the D/A will  also
output to the music room,and if there are people using the D/A there,
they  will be  clobered by your  sounds. So,  send them  a message to
expect your  sounds, as it  is quite  unnerving to  be jolted out  of
meditation by  another's static. See  MAIL.  Ttys  24 and 45  are the
ones in the musiic room.
Or you might move your project to the music room to play your sounds. Type:
AL ⊂prj,prg⊃ ⊂cr⊃ to alias to a tty in the music room.
AL ⊂cr⊃ returns the tty to its previous user. Or,
DET(atch) your job, more to an unused tty in the music room and
ATTACH ⊂job #⊃ [prj,prg] ⊂cr⊃. You are now attached to the new tty.

			******
ANALOG ASPECTS  
Music room:
Switch in back of silver volume box beside Scully 280,
if up, moniters the decks inside the cabinet, if down, the scully.
Scully must be in record mode,  with volume up for channels outputing.
Set Record level to about 5, Input to Line. Put Dolby in Rec mode.
D/A:
Sampling rate of the 4 channel d/a is usually set at 25khz, with the
corresponding low-pass filter cutoff of 12.5khz.
If you have reason to believe the d/a needs to be adjusted, it exists
at KLUDGE BAY 2 in the machine room.  The d/a proper is the topmost 
chasis.  The bottom most chasis is the filter.
Switch positions: channels 4   3   2   1 left to right as you look 
at them.
A/D Nothing is known at this point about the a/d.

				******
	FREEZE METHOD:
If you get squeezed for core, start over doing the following:
R NEWMUS 25 (this specifies 25K core)
	now add input files.
	After compilation write 
⊂ALT⊃FREEZE 
	when frozen, exit to moniter and write
SAV ⊂filename, anything besides NEWMUS⊃
	Your program will be saved in the required core. 
	You now have a dump file with that filename which contains,
	besides NEWMUS, all the data you have put into it. 
	Address it as follows:
RU ⊂dump file name⊃


				******
	EDITING FROM NEWMUS
Given an error in an input list, you have the option to edit the
error in the file without leaving the NEWMUS environment.  Type E, the 
program then moves to the location of the error.  Correct it, then type
⊗X,then GO to return to your location in NEWMUS.
				******



USEFUL TIDBITS:
 	MAG/Pn(usually pn←p2) is note duration. MAG*Pn is fqy.
 	Maximum amplitude processed by the d/a = 2047.
	PRINT ⊂string⊃; will print the values, assuming they exist.
	SEE (array); will display it.
	PUT (FUNCTIONn ⊂from 0→512⊃)⊂number⊃; to change an 
	increment in a function.
MISC. FILES
				
FUNC, a program for using lightpen to write functions, and/or
	to write functions into files. Lightpen works only from III's.
	Type R FUNC. After it enters, type ⊂cr⊃.  It will say
		SEG OR SYNTH?  Say either, usually SEG.
	When the graph is displayed, type L for lightpen, move lightpen to 
	location of the circle of dots, push button on lightpen, and draw.
	To fix a point, hold lightpen at location, type ⊂cr⊃.
		Follow directions until it says 
		ADD TO EXISTING FILE?
	type N(o).  Then it will ask
		TYPE FILE NAME
	write a filename without extension. Then it will say
		TYPE FUNCTION NAME
	so write in a function name. 
	It will create the file with the extension .DAT.
	You can refrence this file from NEWMUS like any other file.
	Later, add functions to this file by saying Y(es) to 
	"ADD TO EXISTING FILE?"

FUNKY[1,MUZ] a file for manipulating arrays.
FUNKY.INF[1,MUZ] for information on FUNKY.

WAVE[1,MUZ] a program to display samples of a sound created 
with NEWMUS.  It will not take files with extensions.  Copy the file
into a file without one, then RU WAVE[1,MUZ) and do what it says.

MONITE[1,MUZ]  a file  containing  the  instrument MONITER,  used  to
display  word blocks  in NEWMUS  while they are  being computed.   It
isn't an instrument you will hear, but a kind of  visual loudspeaker.
So it's function is to display another  instrument .  So load it with
your  instrument,  and  write  a  perameter  list  for MONITER  where
P1=starting time,  P2=duration, P3 is  the amplitude,  and P4 is  how
often to display. Typical values might be 0 1 1000 2;

INFORMATION FILES
MUSIC.TVR[UP,DOC]
SCORE.LCS[UP,DOC]
ABRIDGED EDIT MODE COMMAND LIST
	α MEANS ⊂CONTROL⊃ KEY
	β   "   ⊂META⊃    "
	⊗   "   ⊂META-CONTROL⊃
	⊂cr⊃ "  ⊂RETURN⊃
	|   "   YOU HAVE A CHOICE BETWEEN WHAT`S IN THE BRACKETS
				******
	E EDITOR MODE COMMANDS
ET ⊂FILENAME⊃ TO EDIT A FILE
CET ⊂FILENAME⊃ TO CREATE A FILE.

	MISC.
⊂FORM⊃ KEY WINDOWS AND PAGES AUTOMATICALLY.
⊗P GOES TO NEXT PAGE
⊗W MOVES BOTTOM LINE TO TOP.
⊗J   "   CURRENT  "   "  "  .
⊗L   "   TOP      "   " BOTTOM.
⊗⊂PAGE #⊃⊗P MOVES TO THAT PAGE.
⊂alt⊃ ERASES COMMANDS.
⊂RPT⊃⊗D DELETES LINE.
⊗⊂RPT⊃C DUPLICATES A NUMBER OF LINES.
⊗Q DUPLICATES A LINE ABOVE CURRENT AND MOVES ARROW TO IT.
α⊂SPACE⊃ MOVES CURSOR TO THE RIGHT. α⊂VT⊃ MOVES IT BACK.
TY⊂FILENAME⊃ TO TYPE A FILE ON THE MONITER.
α⊂BREAK⊃ STOPS SCROLLING.
α⊂TAB⊃ MOVES CURSOR TO END OF LINE. 
α ⊂CR⊃ TO CONTINUE A PROGRAM IF YOU CUT YOURSELF OFF.

	INSERT MODE
⊗⊂CR⊃ ENTERS INSERT MODE.
α⊂CR⊃ LEAVE INSERT MODE.
⊂ALT⊃ ELIMINATES THE GAP IF NOTHING IS ENTERED ON LINE.
⊂RPT#⊃⊗⊂CR⊃ INSERTS BLANK LINES WITHOUT ENTERING INSERT MODE.

	ATTACH MODE
⊂RPT⊃|⊗F⊗R ENTERS ATTACH MODE                            
⊗E TERMINATES AND UPDATES LOCATION OF ATTACHED LINE.
⊗R RETURNS LINES TO ORIGINAL PLACE
⊗K KILLS LINES ATTACHED.
⊗E LEAVES ATTACH MODE.

	EXTEND MODE
⊗X ENTERS THE MODE.
⊗X "MARK" MOVES MATERIAL BELOW ARROW TO NEXT PAGE.
⊗X "DELETE" ELIMINATES PAGE MARK BETWEEN ONE PAGE AND THE NEXT.

	TO BREAK A LINE
⊗⊂CR⊃ BREAKS THE LINE AT CURSOR AND ENTERS INSERT MODE.
β⊂CR⊃   "    "    "   "     "   BUT NOTHING ELSE.
(α⊂CR⊃ INDICATES LINE TOO WIDE IF LINE INDENTS TO LEFT.)

	TO INSERT IN A LINE
β⊂LETTERS⊃|⊂SPACE⊃|⊂TAB⊃|⊂BS⊃.
αI TO ADD CHARACTERS IN A LINE WITHOUT HAVING TO HOLD DOWN THE β KEY.

	SEARCH MODE
⊗F⊂STATEMENT STRING⊃ FINDS THE VERBATEM STRING, COUNTS LINES TO THAT LINE,
⊗X FIND_⊂STRING⊃⊂CR⊃. SEARCHES ACROSS PAGES TO FIND THE STRING.
αS ⊂STRING⊃ MOVES CURSOR WITHIN LINE TO THE STRING LOCATION.

				******
	TV EDITOR COMMANDS
TV EDIT A FILE WITH TV.
CTV CREATE A FILE WITH TV.
⊗X "SWITCH"⊂FILENAME⊃ MOVES ATTACHED LINES TO NEW FILE.                 
				******
	TO MOVE INFORMATION BETWEEN FILES
TV ⊂File with info⊃ to locate it.
→ place cursor at top of info.
⊗F⊂bottom line of info⊃⊗A to attach info.
⊗X SWITCH ⊂filename of destination file⊃.
				******
	AIDS TO EDITING
DIR lists all files on the disk in this prj,prg.
DEL ⊂filename⊃ will delete that file.
DEL *.*[PRG,PRJ]/ASK will sequence through files asking to save or not.
α⊂CR⊃ IF THE MONITOR DIDN'T LIKE YOUR COMMAND, WILL PUT IT IN EDIT MODE.
				******
	JUSTIFYING PAGES
⊗A TO BOTTOM LINE, THEN ⊗X JU.
CHANGES AND ADDITIONS

It is now possible to play sounds through the d/a as soon as they are
compiled in NEWMUS.  To do so, add the code "DA:n.n" where n is the length
of the sound file to be played in seconds (don't write integer values,the
dot is aparently necessary). This statement is placed in the PLAY statement
thus:
PLAY DA:1.0; FOO 0 1 A 1000;FINISH;